Skip to content

chore: second-pass cruft cleanup - #414

Merged
kentcdodds merged 8 commits into
mainfrom
cursor/cruft-second-pass-e9ec
May 9, 2026
Merged

kentcdodds merged 8 commits into
mainfrom
cursor/cruft-second-pass-e9ec

Conversation

@kentcdodds

@kentcdodds kentcdodds commented May 9, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #411 — concrete leftovers I found by tracing imports and config references.

Findings and changes

Orphan modules (only their own tests / no callers)

  • packages/worker/src/mcp/capabilities/coding/fetch-markdown-doc.ts — kody_official_guide inlines its own fetch in kody-official-guide.ts; nothing imports fetchMarkdownPreferredDoc / MARKDOWN_PREFERRED_ACCEPT.
  • packages/worker/src/mcp/ui-artifacts-embed.ts (+ its .node.test.ts) — buildUiArtifactEmbedText had no remaining callers; the legacy app-search vectorize path that used it is gone.
  • packages/worker/src/mcp/ui-artifact-parameters.ts (+ its .node.test.ts) — normalizeUiArtifactParameters / parseUiArtifactParameters / applyUiArtifactParameters / uiArtifactParameterSchema were only referenced by their own test.
  • packages/shared/src/ui-artifact-parameters.ts — became orphan after the worker module above and buildAppSourceFiles are removed.
  • buildAppSourceFiles in packages/worker/src/repo/source-templates.ts — no callers anywhere; only buildJobSourceFiles is used.

Dead helpers in packages/worker/src/remote-connector/utils.ts

  • Drop isJsonRpcEnvelope, jsonResponse, createJsonRpcResultResponse, createJsonRpcErrorResponse — none are imported anywhere.
  • Drop parseJsonRpcMessage, which was an identity function; session.ts now uses the value directly.

Stale config / docs

  • packages/worker/project.json — build target listed build-codemode-sandbox-modules in dependsOn, but that target was removed alongside the sandbox modules artifact in 3bd7e38. Nx silently ignored it.
  • tsconfig-tools.json and docs/contributing/typescript-setup.md — both referenced docs/post-download.ts, which is not in the repo.

Unused style tokens

  • packages/worker/client/styles/tokens.ts — drop mq.desktop, colors.primarySoftSubtle, colors.primarySoftHover, and shadows.lg.
  • packages/worker/public/styles.css — drop the now-unreferenced --shadow-lg and --shadow-lg-dark custom properties.

Format gate fix

  • packages/worker/client/mcp-apps/kody-ui-utils-contract.ts had a stray trailing blank line that was making format:check (and therefore validate) red on main. Re-ran oxfmt on it.

Verification

  • npm run typecheck — pass.
  • npm run lint — pass (0 warnings, 0 errors).
  • npm run format:check — pass (after the trailing-blank-line fix).
  • npm run test — 117 files / 585 tests pass.
  • npm run test:e2e:run — 3 Playwright specs pass.
  • npm run test:mcp — 2 MCP tests pass.

Things left for separate decision (each launched as its own Cursor Cloud agent / PR)

  • packages/worker/src/repo/legacy-inline-sources-migration.node.test.ts
  • packages/worker/src/jobs/jobs-codemode-only-migration.node.test.ts
  • packages/worker/src/email/unified-email-receipt-migration.node.test.ts

These exercise long-shipped structural migrations and read low-signal but do guard replayability if anyone edits an old .sql file. Drop or keep at your discretion.

Open in Web Open in Cursor 

Summary by CodeRabbit

  • Chores

    • Updated build configuration and TypeScript compiler include list.
    • Adjusted contributor docs for TypeScript setup.
  • Refactor

    • Simplified JSON-RPC handling and consolidated remote-connector utilities.
    • Removed UI artifact parameter handling and related app-template generation.
    • Removed markdown-preferred fetching capability.
  • Style

    • Simplified design tokens and CSS shadows; removed large-shadow and specific color variants.
  • Tests

    • Removed several tests covering UI artifact parameter and embed formatting.
  • New Features

    • Added generated UI runtime metadata and import-map helper.

cursoragent and others added 7 commits May 9, 2026 02:24
The kody_official_guide capability inlines its own fetch helper in
kody-official-guide.ts; nothing else references fetchMarkdownPreferredDoc
or MARKDOWN_PREFERRED_ACCEPT, so the module is dead.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
buildUiArtifactEmbedText has no callers outside its own test, so the
embed helper and its test are dead. The previous app-search vectorization
flow that consumed it has been gone since the legacy inline-source
cleanup.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
normalizeUiArtifactParameters / parseUiArtifactParameters /
applyUiArtifactParameters and uiArtifactParameterSchema were only
referenced by their own test. The only production consumer of the
shared UiArtifactParameter types was buildAppSourceFiles, which has
no remaining callers either, so the worker module, the shared
parameter types, the dead source template, and the orphan test all
go away together.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Drop isJsonRpcEnvelope, jsonResponse, createJsonRpcResultResponse,
createJsonRpcErrorResponse, and the identity parseJsonRpcMessage
wrapper from remote-connector/utils.ts. None had callers outside the
file itself, and parseJsonRpcMessage was just returning its argument,
so session.ts can use the JSONRPCMessage value directly.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
The codemode sandbox modules artifact was deleted in 3bd7e38 ("Remove
stale codemode sandbox modules file"), but the build target kept the
now-nonexistent dependency in dependsOn. Nx silently ignores missing
targets, so this has been a no-op string ever since.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
There is no docs/post-download.ts in the repository, but tsconfig-tools.json
listed it under include and typescript-setup.md called it out as a Tools
environment file. Both references are stale leftovers.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
mq.desktop, colors.primarySoftSubtle, colors.primarySoftHover, and
shadows.lg had no callers across the client. Their backing CSS custom
properties (--shadow-lg / --shadow-lg-dark) were also unreferenced and
go away with them.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented May 9, 2026 •

Copy link
Copy Markdown

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e423ef9a-d3ec-44a2-9005-92872916aa5e

📥 Commits

Reviewing files that changed from the base of the PR and between ab70a33 and f7c7ef7.

📒 Files selected for processing (1)
  • packages/worker/client/mcp-apps/kody-ui-utils-contract.ts
💤 Files with no reviewable changes (1)
  • packages/worker/client/mcp-apps/kody-ui-utils-contract.ts

📝 Walkthrough

Walkthrough

This PR systematically removes unused UI artifact parameter types, embed text generation utilities, markdown document fetching capabilities, and related test coverage. It simplifies remote connector JSON-RPC handling by eliminating helper utilities and reducing duplication. Design tokens are pruned to remove unused color and media query variants. Build configuration and TypeScript setup are updated to reflect these removals.

Changes

Feature and Type Removal

Layer / File(s) Summary
Shared Type Definitions Removed
packages/shared/src/ui-artifact-parameters.ts
uiArtifactParameterTypes, UiArtifactParameterType, UiArtifactParameterInput, and UiArtifactParameterDefinition exports deleted.
Worker Parameter Implementation Removed
packages/worker/src/mcp/ui-artifact-parameters.ts
Module removed: Zod schema, normalize/parse/apply functions, and internal assertion helpers deleted.
UI Artifact Embed Text Removed
packages/worker/src/mcp/ui-artifacts-embed.ts
buildUiArtifactEmbedText and defaultAppEmbedMaxChars deleted.
Source Template Generation Simplified
packages/worker/src/repo/source-templates.ts
UiArtifactParameterInput import removed; buildAppSourceFiles export deleted; buildJobSourceFiles remains.
Markdown Document Fetching Capability Removed
packages/worker/src/mcp/capabilities/coding/fetch-markdown-doc.ts
MARKDOWN_PREFERRED_ACCEPT and fetchMarkdownPreferredDoc removed.
Remote Connector JSON-RPC Utilities Simplified
packages/worker/src/remote-connector/utils.ts
packages/worker/src/remote-connector/session.ts
Removed exports: jsonResponse, isJsonRpcEnvelope, createJsonRpcResultResponse, createJsonRpcErrorResponse, parseJsonRpcMessage; session handler now inspects JSONRPCMessage directly.
Design Tokens Cleaned Up
packages/worker/client/styles/tokens.ts
packages/worker/public/styles.css
Removed color variants primarySoftSubtle and primarySoftHover; removed shadow variant lg; removed media query desktop; removed --shadow-lg and --shadow-lg-dark CSS vars and their dark mappings.
Tests for Removed Functionality
packages/worker/src/mcp/ui-artifact-parameters.node.test.ts
packages/worker/src/mcp/ui-artifacts-embed.node.test.ts
Test files removed.
Build and Configuration Updates
packages/worker/project.json
tsconfig-tools.json
docs/contributing/typescript-setup.md
build target dependsOn changed to ["build-client"]; docs/post-download.ts removed from tsconfig include and docs list.
Generated UI Runtime Contract Added
packages/worker/client/mcp-apps/kody-ui-utils-contract.ts
Added runtime/bootstrap-related types, generatedUiRuntimeModuleSpecifier, and buildGeneratedUiRuntimeImportMap(runtimeScriptHref).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • kentcdodds/kody#63: Directly undoes or removes the UI artifact parameter types/functions and wiring that PR added.
  • kentcdodds/kody#89: Related to worker build wiring; this PR removes the worker dependency on build-codemode-sandbox-modules that #89 previously added.
  • kentcdodds/kody#192: Related removals around markdown/document-fetching capabilities overlapping this PR's deletion of fetchMarkdownPreferredDoc.

Poem

🐰 Hopped through code with careful paws,
Pruned the branches, fixed the flaws,
Parameters tucked, embeds asleep,
Tokens slimmed, and tests ran deep,
A cleaner burrow, code that shines—huzzah!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: second-pass cruft cleanup' accurately describes the main purpose of the PR: removing leftover dead code, unused modules, stale config, and orphaned style tokens across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/cruft-second-pass-e9ec

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kentcdodds
kentcdodds marked this pull request as ready for review May 9, 2026 02:29
@github-actions

github-actions Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-414.kentcdodds.workers.dev

Worker: kody-pr-414
D1: kody-pr-414-db
KV: kody-pr-414-oauth-kv

Mocks:

oxfmt has been flagging this on every PR (the validate format:check step
fails on main because of it). Re-run oxfmt to make the gate green.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kentcdodds
kentcdodds merged commit 8b7d83b into main May 9, 2026
5 checks passed
@kentcdodds
kentcdodds deleted the cursor/cruft-second-pass-e9ec branch May 9, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants